﻿using Infrastructure.Config;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;
using TencentCloud.Common;

namespace OtherLib.TenXun
{
    public static class TenXunConfig
    {
        public readonly static string SecretId;
        public readonly static string SecretKey;

        public readonly static string Cos_Region;
        public readonly static long Cos_DurationSecond;
        public readonly static string Cos_Bucket;
        public readonly static string Cos_Domain;

        public readonly static Credential Cred;
        static TenXunConfig()
        {
            if (string.IsNullOrWhiteSpace(SecretId))
            {
                var aliSmsConfig = ApplicationConfig.GetConfig().GetSection("TenXunSecret");

                SecretId = aliSmsConfig["AccessKeyId"];
                SecretKey = aliSmsConfig["Secret"];

                var tenXunCosConfig = ApplicationConfig.GetConfig().GetSection("TenXunCos");

                Cos_Region = tenXunCosConfig["Region"];
                Cos_DurationSecond = tenXunCosConfig.GetValue<long>("DurationSecond");
                Cos_Bucket = tenXunCosConfig["Bucket"];
                Cos_Domain = tenXunCosConfig["Domain"];

                Cred = new Credential
                {
                    SecretId = TenXunConfig.SecretId,
                    SecretKey = TenXunConfig.SecretKey
                };
            }
        }
    }
}
